package com.xiaoniu.mc.hystrix;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * @类描述：
 * @创建人：林继丰
 * @创建时间：2017/9/15 17:45
 * @版权：Copyright (c) 深圳市牛鼎丰科技有限公司-版权所有.
 */
public class HystrixCommandInterceptor implements MethodInterceptor {

    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        String fullMethodName = methodInvocation.getThis().getClass().getName()+"."+methodInvocation.getMethod().getName();
        HystrixConfig config = FuseContext.methodNameMapConfig.get(fullMethodName);
        SelfHystrixCommand command = new SelfHystrixCommand(methodInvocation,config);
        return command.execute();
    }
}
